package pl.edu.agh.agents.planner;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import pl.edu.agh.agents.agent.Agent;
import pl.edu.agh.agents.path.Path;
import pl.edu.agh.agents.state.State;
import pl.edu.agh.agents.state.StateSpace;

public abstract class Planner {
	StateSpace space = StateSpace.getInstance();
	Algorithm alg = space.getAlgorithm();
	
	public Path calculatePath(Agent agent){
		return calculatePath(agent, space.getCurrentPaths(), false);
	}
	
	public Path calculatePath(Agent agent, Map<Agent, Path> paths, boolean cp){
		paths.putAll(space.getCurrentPaths());
		return calculatePath(agent, paths, cp, new ArrayList<State>());
	}
	
	public Path calculatePath(Agent a, State b, Map<Agent, Path> paths, boolean cp, List<State> importantStates){
		paths.putAll(space.getCurrentPaths());
		return alg.calculatePathWithFuture(a, b, paths, cp, importantStates);

	}
	
	public Path calculatePath(Agent agent, Map<Agent, Path> paths, boolean cp, List<State> badStates){
		paths.putAll(space.getCurrentPaths());
		
		if(agent.getLookAheadStates()>1 || cp){
			return alg.calculatePathWithFuture(agent, agent.getGoalState(), paths, cp, badStates);
		}
		return alg.calculatePath(agent);

	}
	
	public Path getBestPath(Agent agent){
		return alg.calculatePath(agent);
	}
	
	public Path getBestPath(State a, State b){
		return alg.calculatePath(a, b);
	}
}
